<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="../static/css/prism.css" rel="stylesheet" />
</head>

<body>
    <strong style="color:blueviolet">本节无script演示</strong>

    <h2>trim方法</h2>
    <p>去除字符串两端的空格（空白字符，类似于python的strip方法），返回一个新字符串，不改变原字符串</p>
    <pre><code class="language-javascript">'\r\nitbaizhan \t  '.trim() // 'itbaizhan'</code></pre>

    <p>ES6扩展方法，`trimEnd()`和`trimStart()`方法</p>
    <pre><code class="language-javascript">"   itbaizhan   ".trimEnd(); //    itbaizhan
"   itbaizhan   ".trimStart(); // itbaizhan   </code></pre>

    <script src="../static/js/prism.min.js"></script>
</body>

</html>